<?php /*a:1:{s:33:"D:\work\tp\view\signin\index.html";i:1652882024;}*/ ?>
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <script src="https://unpkg.com/axios/dist/axios.min.js"></script>
    <link rel="stylesheet" href="http://127.0.0.1:8000/layui/css/layui.css">
    <link rel="stylesheet" href="http://127.0.0.1:8000/layer/layer.js">
    <script src="http://127.0.0.1:8000/layui/layui.js"></script>
    <link rel="stylesheet" href="http://127.0.0.1:8000/static/login.css">
</head>
<body>
<div class="login_container">
    <div class="avater_box">
        <img src="http://127.0.0.1:8000/static/img.png" alt="">
    </div>
    <form id="login">
        <input type="text"  value="jack" name="username"><span id="usernametip"></span><br/>
        <input type="password" value="123456" name="password"><span id="passwordtip"></span><br/>
        <div class="yzm-content">
            <input type="text"  autocomplete="off" name="verifycode" placeholder="请输入验证码">
            <div id="yzm"><?php echo captcha_img(); ?></div>
        </div>
        <input type="submit" value="登录" id="submit">
        <span style="margin-left: 200px;color:#908f8f">管理员身份登录
        </span>
        <input type="checkbox" id="chebox" style="width: 15px;height: 15px;border-radius: 50%;position: relative;top: 3px">
    </form>
</div>

<script>
    // console.log((new Date()).valueOf())
    var login = document.getElementById('login')
    var submit = document.getElementById('submit')
    var yzm = document.getElementById('yzm')
    var yamimg = yzm.getElementsByTagName('img')
    var chebox= document.getElementById('chebox');

    // console.log(yamimg)
    login.addEventListener('submit',function (e){

        e.preventDefault()
    })
    submit.addEventListener('click', async () =>{
        var t = chebox.checked?1:0
        var username = login.username.value
        var password = login.password.value
        var verifycode = login.verifycode.value
        const result = await axios.post('login',{username,password,verifycode,login_at:(new Date()).valueOf(),t:t})
        if(result.data.state && result.data.state!==200)
        {
            return layer.msg(result.data.message, {
                icon: 0,
                time: 1000
            },function() {
                window.location.reload()
            })
        }else{
            layer.msg('登录成功即将跳转~', {
                icon: 1,
                time: 1000
            },function() {
                if(t===1) {
                    window.location.href = '/admins'
                }else{
                    window.location.href = '/home'
                }
            })
        }
    })

</script>
</body>
</html>